<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>订单提交</title>
		<meta name="Description" content="" />
		<meta name="Keywords" content="" />
		<meta name="format-detection" content="telephone=no, email=no" />
		<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
		<!-- 忽略页面中的数字识别为电话，忽略email识别 -->
		<meta name="applicable-device" content="mobile" />
		<meta name="apple-mobile-web-app-title" content="" />
		<!-- 添加到主屏后的标题（iOS 6 新增） -->
		<meta name="apple-mobile-web-app-capable" content="yes" />
		<!-- 是否启用 WebApp 全屏模式 -->
		<meta name="HandheldFriendly" content="true" />
		<!-- 针对手持设备优化，主要是针对一些老的不识别viewport的浏览器，比如黑莓 -->
		<meta name="author" content="Jack" />
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<script src="../../js/flexible.js" type="text/javascript" charset="utf-8"></script>
		<link rel="stylesheet" type="text/css" href="../../style/jquery_css/weui.css" />
		<link rel="stylesheet" type="text/css" href="../../style/jquery_css/jquery-weui.css" />
		<link rel="stylesheet" type="text/css" href="../../swiper/css/swiper.min.css" />
		<link rel="stylesheet" type="text/css" href="../../style/public.css" />
		<link rel="stylesheet" type="text/css" href="../../style/icon_font/iconfont.css" />
		<link rel="stylesheet" type="text/css" href="../../style/main.css" />
		<link rel="stylesheet" type="text/css" href="../../style/icon.css" />
		<link rel="stylesheet" type="text/css" href="../../style/car.css" />
	</head>

	<body class="body-bg">
		<div class="header-nav is-postion">
			<div class="cen-mony">
				<div class="header-flex">
					<i class="return-2" onclick="window.history.go(-1)"></i>
				</div>
				<div class="header-flex">订单提交</div>
				<div class="header-flex"></div>
			</div>
		</div>
		<div class="UDC-max-box">
			<div class="top-my-UDC" style="padding-bottom: 0;">

				<ul class="MUDC-ul">

					<li class="border-topp">
						<div class="inile-block this_font">客服姓名</div>
						<div class="inile-block float-tib">
							<input type="text" placeholder="请输入客服姓名" class="TB-num" id="name" />
						</div>
					</li>
					<li class="border-topp">
						<div class="inile-block this_font">客户手机号</div>
						<div class="inile-block float-tib">
							<input type="number" placeholder="请输入手机号" class="TB-num" id="phone" maxlength="11"/>
						</div>
					</li>
					<!-- <li class="border-topp">
						<div class="inile-block this_font">运营商</div>
						<div class="inile-block float-tib">
							<select name="type" id="type" style="padding:5px 20px">
								<option value="1">联通</option>
								<option value="2">移动</option>
								<option value="3">电信</option>
							</select>
						</div>
					</li> -->
					<li class="border-topp">
						<div class="inile-block this_font">办理套餐</div>
						<div class="inile-block float-tib">
							<select name="type" id="tc" style="padding:5px 20px">
		
							</select>
						</div>
					</li>
					<li class="border-topp">
						<div class="inile-block this_font">担保方式</div>
						<div class="inile-block float-tib">
							<input type="text" placeholder="请输入担保方式" class="TB-num" id="dbfs" />
						</div>
					</li>
					<li class="border-topp">
						<div class="inile-block this_font">礼品收货地址</div>
						<div class="inile-block float-tib">
							<textarea name="address" row="4" id="address" placeholder="请输入收货地址"  class="TB-num"></textarea>				
						</div>
					</li>

				</ul>

			</div>


			<!--<div class="identity-cen">
				<div class="uploading-font">请拍摄并上传行驶证</div>
				<div class="infuse">注：请核实后再上传，上传后不可修改。</div>
				<div>
					<div class="driving-card1 id-card" onclick="main_obj.uploading_fn1('upload-card1','driving-card1')"></div>
					<div class="driving-card2 id-card" onclick="main_obj.uploading_fn1('upload-card2','driving-card2')"></div>
					<input id="upload-card1" name="image" accept="image/*" type="file" style="display: none">
					<input id="upload-card2" name="image" accept="image/*" type="file" style="display: none">
				</div>
			</div>-->
			<div class="TB-box">
				<button class="sbmit-btn" style="width: 100%;" onclick="main_obj.submit_fn()">提交</button>
			</div>
		</div>
	</body>
	<script src="../../js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../js/weiUI/jquery-weui.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../js/api/api_url.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../js/api/port_url.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../swiper/js/swiper.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../js/dySelect.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		var user_arr = JSON.parse(sessionStorage.getItem('users_info'));
		$(function() {
			main_obj.my_data();
		})
		var receive_img = '';
		var fileall = []; //存放图片的容器
		var main_obj = {
			submit_fn: function() {
				var reg = /^1(3|4|5|6|7|8|9)\d{9}$/;
				if($.trim($('#name').val()) == '') {
					$.toast("请输入客户姓名!", "text");
					return false;
				}
				if($.trim($('#phone').val()) == '') {
					$.toast("请输入手机号!", "text");
					return false;
				}
				if(!reg.test($.trim($('#phone').val()))) {
					$.toast("请输入正确的手机号码!", "text");
					return false;
				}
				if($.trim($('#tc').val()) == '') {
					$.toast("请输入办理套餐!", "text");
					return false;
				}
				if($.trim($('#dbfs').val()) == '') {
					$.toast("请输入担保方式!", "text");
					return false;
				}
				if($.trim($('#address').val()) == '') {
					$.toast("请输入收货地址!", "text");
					return false;
				}
				var formData = new FormData();
				
				formData.append("access_token", '41ab23e7efb238797fe39cc30f6b21d3');
				formData.append("user_id", user_arr.id);
				formData.append("phone", $.trim($('#phone').val()));
				formData.append("name", $.trim($('#name').val()));
				formData.append("tc", $.trim($('#tc').val()));
				formData.append("dbfs", $.trim($('#dbfs').val()));
				formData.append("yys", $.trim($('#tc option:selected').attr("data")));
				formData.append("address", $.trim($('#address').val()));
				$.ajax({
					url: config_URL.api + URL.myOrderAdd, //请求的url地址
					type: 'POST',
					dataType: 'json',
					data: formData,
					cache: false,
					processData: false,
					contentType: false,
					success: function(res) {
						console.log(res)
						if(res.code == 0) {
							$.toast('订单提交成功！', "text");
							location.href = '../wallet/order_list.html'
//							main_obj.my_data();
						} else {
							$.toast(res.msg, "text");
						}

					},
					error: function(rul) {
						console.log('网络出错')
					}
				});
			},
			uploading_fn1: function(uploading, upload) {
				$("#" + uploading + "").click();
				$("#" + uploading + "").on("change", function() {
					var imgFiles = $(this)[0].files[0];
					if(fileall.length>2){
						fileall.shift();
					}else{
						fileall.push(imgFiles);
					}
					var reader=new FileReader();
					  reader.onload=function(e){
					  //console.log( reader.result);  //或者 e.target.result都是一样的，都是base64码
					  $('.'+upload+'').html('<img src="'+reader.result+'" class="up-img"/>');
					}  					
					reader.readAsDataURL(this.files[0]);
					     
				});
			},
			//我提交的资料
			my_data:function(){
				$.ajax({
				url: config_URL.api+URL.tcList, //请求的url地址
				dataType: "json", //返回格式为json
				data:{
					access_token:'41ab23e7efb238797fe39cc30f6b21d3'
				},
				type: "POST", //请求方式
				success: function(res) {
					console.log(res)
					var data = res.data;
					if(res.code==0){
          				var tit_html = '';
						for(var i in data) {
							tit_html += '<option value="'+data[i].id+'" data="'+data[i].yys+'">'+data[i].yys+' '+ data[i].title + '</div>'
						}
						$("#tc").html(tit_html);
					}else{
						$.toast(res.msg, "text");
					}
					
					
				},
				error: function(rul) {
					console.log('网络出错')
				}
			});
			}
		}
	</script>

</html>